package com.link.base.base.mpconfig.controller;

import com.link.base.base.mpconfig.model.DepartureReportImg;
import com.link.base.base.mpconfig.service.DepartureReportImgService;
import com.link.core.cllog.LCLogger;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * 小程序离店报告图片
 *
 * @author: 闫有霞
 * @date: 2019/12/19
 */

@Controller
@RequestMapping("/link/departureReportImg")
public class DepartureReportImgController extends BasicController<DepartureReportImg> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private DepartureReportImgService departureReportImgService;

    @Override
    public BasicService<DepartureReportImg> getBasicService() throws Exception {
        return departureReportImgService;
    }

    /**
     *@createdBy 闫有霞
     *@date 2018/11/30
     *@methods: updateValid
     *@param: DepartureReportImg entity
     *@return:
     *@description: 更新状态
     **/

    @RequestMapping(value = "/updateValid")
    @ResponseBody
    public Map<String, Object> updateValid(@RequestBody DepartureReportImg entity, HttpSession session,
                                           HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> result = new HashMap<>();
        try {
            departureReportImgService.updateValid(entity);
            result.put("success", true);
            result.put("result", entity);
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("result", e.getMessage());
        }
        return result;
    }
}
